package com.xxy.mapper;

import com.xxy.pojo.Category;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author Lenovo
* @description 针对表【category】的数据库操作Mapper
* @createDate 2024-01-28 17:09:27
* @Entity com.xxy.pojo.Category
*/
@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
    //新增
    @Insert("insert into big_event.category(category_name,category_alias,create_user,create_time,update_time) " +
            "values(#{category_name},#{category_alias},#{id},now(),now())")
    void add(String category_name, String category_alias, Integer id);

    //查询所有
    @Select("select * from big_event.category where create_user = #{userId}")
    List<Category> list(Integer userId);


    //根据id查询
    @Select("select * from category where id = #{id}")
    Category findById(Integer id);


    //更新
    @Update("update category set category_name=#{category_name},category_alias=#{category_alias},update_time=#{update_time} where id=#{id}")
    void update(Category category);


    //根据id删除
    @Delete("delete from category where id=#{id}")
    void deleteById(Integer id);
}




